<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
    :okButtonProps="{ props: {disabled: disableSubmit} }"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <!-- 主表单区域 -->
      <a-form :form="form">
        <a-row>

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="所属公司" v-is-group :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-company-select-tag placeholder="请选择所属公司" :disabled="disableSubmit" v-decorator="[ 'companyId', validatorRules.companyId]"-->
<!--                                    :trigger-change="true" @change="getAssetCode"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->



          <a-col :xs="24" :sm="12">
            <a-form-item label="取得方式" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <!--              <span v-if="disableSubmit" >{{model.assetClass}}</span>-->
              <!--              <j-dict-select-tag v-else type="list" v-decorator="['assetClass', validatorRules.assetClass]" :trigger-change="true" dictCode="zcgl_asset_classify" placeholder="请选择资产类别"/>-->
              <j-search-select-tag type="list" v-decorator="['assetClass']"
                                   :trigger-change="true" dict="zcgl_asset_classify" :disabled="disableSubmit"
                                   placeholder="请选择取得方式"/>
            </a-form-item>
          </a-col>

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="资产类别" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-search-select-tag type="list" v-decorator="['zcType', validatorRules.zcType]"-->
<!--                                   :trigger-change="true" dict="gf_zcgl_asset_type" :disabled="disableSubmit"-->
<!--                                   placeholder="资产类别"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item label="请选择资产分类" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-search-select-tag type="list" v-decorator="['assetType']"
                                   :trigger-change="true"  dict="gf_zcgl_asset_type" :disabled="disableSubmit"
                                   placeholder="请选择资产分类"/>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12">
            <a-form-item label="资产名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['assetName']" :disabled="disableSubmit"
                       placeholder="请输入资产名称"></a-input>
            </a-form-item>
          </a-col>

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="所属区域" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-tree-select-->
<!--                :disabled="disableSubmit"-->
<!--                v-decorator="['regionId', validatorRules.regionId]"-->
<!--                placeholder="请选择区域"-->
<!--                dict="zcgl_region,region_name,id"-->
<!--                pidField="parent_id"-->
<!--                pidValue=""-->
<!--              />-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          condition='{"del_flag":"0"}'-->
<!--          <a-col :xs="24" :sm="12"  v-show="disableSubmit">-->
<!--            <a-form-item label="所属区域" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['regionId_dictText']"-->
<!--                       :disabled="disableSubmit" placeholder=""></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->


          <a-col :xs="24" :sm="12">
            <a-form-item label="产权单位" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['propertyRightUnit']"
                       :disabled="disableSubmit" placeholder="请输入产权单位"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item label="产权证编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['propertyRightCode']"
                       :disabled="disableSubmit" placeholder="请输入产权证编号"></a-input>
            </a-form-item>
          </a-col>



          <a-col :span="24">
            <a-form-item label="坐落位置" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <a-textarea v-decorator="['site']" :disabled="disableSubmit" rows="2"
                          placeholder="请输入坐落位置"></a-textarea>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12">
            <a-form-item label="土地面积(亩)" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['landArea', {}]" :disabled="disableSubmit"
                              placeholder="请输入土地面积(亩)"
                              style="width: 100%"/>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item label="土地面积(平方)" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['landAreaSquare', {}]" :disabled="disableSubmit"
                              placeholder="请输入土地面积(平方)"
                              style="width: 100%"/>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12">
            <a-form-item label="评估入账金(万元)" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['evaluateFees', {}]" :disabled="disableSubmit"
                              placeholder="请输入评估入账金(万元)"
                              style="width: 100%"/>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12">
            <a-form-item label="土地用途" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['landUse']" :disabled="disableSubmit" placeholder="请输入土地用途"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12">
            <a-form-item label="土地等级" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['landLevel', {}]" :disabled="disableSubmit"
                       placeholder="请输入土地等级" />

            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12">
            <a-form-item label="抵押情况" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['mortgageSituation', {}]" :disabled="disableSubmit"
                       placeholder="请输入抵押情况"></a-input>
            </a-form-item>
          </a-col>
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="经营情况" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['businessCircumstance', validatorRules.businessCircumstance]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入经营情况"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="接收时间" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-date :disabled="disableSubmit" placeholder="请选择接收时间"-->
<!--                      v-decorator="['receiptTime', validatorRules.receiptTime]" :trigger-change="true"-->
<!--                      style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="接收类型" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['receiptType', validatorRules.receiptType]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入接收类型"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="管理单位" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--&lt;!&ndash;              <a-input v-decorator="['managementUnitId', validatorRules.managementUnitId]"&ndash;&gt;-->
<!--&lt;!&ndash;                       :disabled="disableSubmit" placeholder="请输入管理单位"></a-input>&ndash;&gt;-->
<!--              <j-company-select-tag :disabled="disableSubmit" placeholder="请选择管理单位" v-decorator="[ 'managementUnitId', validatorRules.managementUnitId]" :trigger-change="true"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="权利类型" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-search-select-tag type="list" v-decorator="['landAuthorityType', validatorRules.landAuthorityType]"-->
<!--                                   :trigger-change="true" dict="zcgl_land_authority_type" :disabled="disableSubmit"-->
<!--                                   placeholder="请选择权利类型"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="权属情况" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-search-select-tag type="list" v-decorator="['ownershipSituation', validatorRules.ownershipSituation]"-->
<!--                                   :trigger-change="true" dict="zcgl_ownership_situation" :disabled="disableSubmit"-->
<!--                                   placeholder="请选择权属情况"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="使用权证号" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['licenseNumber', validatorRules.licenseNumber]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入使用权证号"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="收款税率" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['collectionRate', validatorRules.collectionRate]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入收款税率" style="width: 100%"></a-input-number>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

          <!--          <a-col :xs="24" :sm="12">-->
          <!--            <a-form-item label="商户名称" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
          <!--              <a-input v-decorator="['merchantName']"-->
          <!--                        :disabled="disableSubmit" placeholder="请输入商户名称"></a-input>-->
          <!--            </a-form-item>-->
          <!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-search-select-tag type="list" v-decorator="['status']" :trigger-change="true"
                                   dict="zcgl_asset_status" :disabled="disableSubmit" :valueExclude="[1]" @change="statusChange" placeholder="请选择状态"/>
            </a-form-item>
          </a-col>

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="管理人员" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-search-select-tag  :async="true" v-decorator="['managerId']" :disabled="disableSubmit" dict="sys_user,realname,id"-->
<!--                                   placeholder="请选择管理人员"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="楼层" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['floorNumber', validatorRules.floorNumber]" :disabled="disableSubmit"-->
<!--                       placeholder="请输入楼层"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item label="建成年份" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['buildTime']" :disabled="disableSubmit"
                       placeholder="请输入建成年份"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-item label="结构" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['houseStructure']" :disabled="disableSubmit"
                       placeholder="请输入结构"></a-input>
            </a-form-item>
          </a-col>
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="房屋用途" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['houseUse', validatorRules.houseUse]" :disabled="disableSubmit"-->
<!--                       placeholder="请输入房屋用途"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

          <a-col :xs="24" :sm="12">
            <a-form-item label="土地权利性质" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input v-decorator="['landAuthorityNature']" :disabled="disableSubmit"
                       placeholder="请输入土地权利性质"></a-input>
            </a-form-item>
          </a-col>


                    <a-col :xs="24" :sm="12">
                      <a-form-item label="套内面积（m²）" :labelCol="labelCol" :wrapperCol="wrapperCol">
                        <a-input-number v-decorator="['tnArea']"
                                        :disabled="disableSubmit" placeholder="请输入套内面积（m²）" style="width: 100%"/>
                      </a-form-item>
                    </a-col>
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="产权面积（m²）" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['propertyRightArea', validatorRules.propertyRightArea]"-->
<!--                              :disabled="disableSubmit" placeholder="请输入产权面积（m²）" style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item label="建筑面积（m²）" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['coveredArea']" :disabled="disableSubmit"
                              placeholder="请输入建筑面积（m²）"
                              style="width: 100%"/>
            </a-form-item>
          </a-col>
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="出租面积（m²）" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['landUseArea', validatorRules.landUseArea]" :disabled="disableSubmit"-->
<!--                              placeholder="请输入出租面积（m²）"-->
<!--                              style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->


          <a-col :xs="24" :sm="12">
            <a-form-item label="共有面积(平方)" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['totalArea', {}]" :disabled="disableSubmit"
                              placeholder="请输入共有面积(平方)"
                              style="width: 100%"/>
            </a-form-item>
          </a-col>
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="住宅面积" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['residentialArea', {}]" :disabled="disableSubmit"-->
<!--                              placeholder="请输入住宅面积"-->
<!--                              style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="非住宅面积" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['nonResidentialArea', {}]" :disabled="disableSubmit"-->
<!--                              placeholder="请输入非住宅面积"-->
<!--                              style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="门市面积" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['outletsArea', {}]" :disabled="disableSubmit"-->
<!--                              placeholder="请输入门市面积"-->
<!--                              style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item label="总库容(万立方米)" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['totalCapacity', {}]" :disabled="disableSubmit"
                              placeholder="请输入总库容(万立方米)"
                              style="width: 100%"/>
            </a-form-item>
          </a-col>
<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="挂牌面积" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['tradingArea', {}]" :disabled="disableSubmit"-->
<!--                              placeholder="请输入挂牌面积"-->
<!--                              style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="年租金" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['rentYear', {}]" :disabled="disableSubmit"-->
<!--                              placeholder="请输入年租金"-->
<!--                              style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item label="车位数" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <a-input-number v-decorator="['parkingSpaceNumber', {}]" :disabled="disableSubmit"
                              placeholder="请输入车位数"
                              style="width: 100%"/>
            </a-form-item>
          </a-col>

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="土地性质" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-dict-select-tag type="list" v-decorator="['landStatus']" :trigger-change="true"-->
<!--                                 dictCode="zcgl_asset_soiltype" :disabled="disableSubmit" placeholder="请选择土地性质"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xs="24" :sm="12">
            <a-form-item label="房屋性质" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag type="list" v-decorator="['roomType']" :trigger-change="true"
                                 dictCode="zcgl_asset_housetype" :disabled="disableSubmit" placeholder="请选择房屋性质"/>
            </a-form-item>
          </a-col>

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="价值（万元）" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input-number v-decorator="['worth', validatorRules.worth]" :disabled="disableSubmit"-->
<!--                              placeholder="请输入价值（万元）"-->
<!--                              style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->



<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="栋号" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['movieTheater', {}]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入栋号"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="原栋号" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['oldMovieTheater', {}]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入原栋号"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="视觉楼层" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['visualFloor', {}]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入视觉楼层"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="房号" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <a-input v-decorator="['roomNumber', {}]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入房号"></a-input>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="管区" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-dict-select-tag type="list" v-decorator="['regional']"-->
<!--                                 :trigger-change="true" dictCode="zcgl_regional" :disabled="disableSubmit"-->
<!--                                 placeholder="请选择管区"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->





<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="调拔时间" :labelCol="labelCol" :wrapperCol="wrapperCol">-->
<!--              <j-date :disabled="disableSubmit" placeholder="请选择调拔时间" v-decorator="['pullTime']" :trigger-change="true"-->
<!--                      style="width: 100%"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

<!--          <a-col :xs="24" :sm="12">-->
<!--            <a-form-item label="上会时间" :labelCol="labelCol" :wrapperCol="wrapperCol">-->

<!--              <a-input v-decorator="['meetingTime', validatorRules.meetingTime]"-->
<!--                       :disabled="disableSubmit" placeholder="请输入上会时间"></a-input>-->
<!--&lt;!&ndash;              <j-date :disabled="disableSubmit" placeholder="请选择上会时间" v-decorator="['meetingTime']"&ndash;&gt;-->
<!--&lt;!&ndash;                      :trigger-change="true"&ndash;&gt;-->
<!--&lt;!&ndash;                      style="width: 100%"/>&ndash;&gt;-->
<!--            </a-form-item>-->
<!--          </a-col>-->

          <a-col :xs="24" :sm="12" v-show="isDisposal">
            <a-form-item label="资产处置" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-dict-select-tag type="list" v-decorator="['assetDisposal']"
                                 :disabled="disableSubmit" :trigger-change="true" dictCode="asset_disposal" placeholder=""/>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12" v-show="isDisposal">
            <a-form-item label="处置日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-date v-decorator="['assetDisposalDate']"
                      :disabled="disableSubmit" :trigger-change="true" style="width: 100%"/>
            </a-form-item>
          </a-col>

          <a-col :span="24" v-show="isDisposal">
            <a-form-item label="处置户型" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <a-input v-decorator="['disposalRoom',{}]"
                          :disabled="disableSubmit" rows="4" placeholder=""></a-input>
            </a-form-item>
          </a-col>

          <a-col :span="24" v-show="isDisposal">
            <a-form-item label="处置方式" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <a-input v-decorator="['disposalType',{}]"
                       :disabled="disableSubmit" rows="4" placeholder=""></a-input>
            </a-form-item>
          </a-col>

          <a-col :span="24" v-show="isDisposal">
            <a-form-item label="处置情况说明" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <a-textarea v-decorator="['assetDisposalDescription']"
                          :disabled="disableSubmit" rows="4" placeholder=""></a-textarea>
            </a-form-item>
          </a-col>

<!--          <a-col :span="24">-->
<!--            <a-form-item label="产权证地址" :labelCol="labelCol2" :wrapperCol="wrapperCol2">-->
<!--              <a-textarea v-decorator="['addressPropertyDivision', validatorRules.addressPropertyDivision]" rows="2"-->
<!--                          :disabled="disableSubmit" placeholder="请输入产权证地址"></a-textarea>-->
<!--            </a-form-item>-->
<!--          </a-col>-->


          <!--          <a href="http://apis.map.qq.com/tools/locpicker?search=1&type=0&backurl=https://baidu.com&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&referer=myapp">-->
          <!--            <input placeholder="请选择地址" readonly>-->
          <!--          </a>-->



          <a-col :span="24">
            <a-form-item label="备注" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <a-textarea v-decorator="['remark']" :disabled="disableSubmit" rows="2"
                          placeholder="请输入备注"></a-textarea>
            </a-form-item>
          </a-col>

          <a-col :span="24">
            <a-form-item label="资产图片" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <!--              class="avatar-uploader"-->
              <j-image-upload text="上传" v-model="images" :isMultiple="true" :disabled="disableSubmit" :number="6"></j-image-upload>
            </a-form-item>
          </a-col>

          <a-col :span="24" v-show="!disableSubmit">
            <a-form-item label="地图选点" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <iframe id="mapPage" width="100%" height="400px" frameborder=0
                      :src="tencentMapUrl">
              </iframe>
              <!--              <a-textarea v-decorator="['site', validatorRules.site]" :disabled="disableSubmit" rows="2"-->
              <!--                          placeholder="请输入坐落位置"></a-textarea>-->
            </a-form-item>
          </a-col>


          <a-col :span="24" v-show="disableSubmit">
            <a-form-item label="地图位置" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
              <div id="container" style="height:400px;"></div>
            </a-form-item>
          </a-col>

          <a-col :xs="24" :sm="12">
            <a-form-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <j-upload v-decorator="['accessory']" :disabled="disableSubmit" :trigger-change="true"></j-upload>
            </a-form-item>
          </a-col>

        </a-row>
      </a-form>

      <!-- 子表单区域 1-->
      <a-tabs v-show="false" v-model="activeKey" @change="handleChangeTabs">
        <a-tab-pane tab="资产明细" :key="refKeys[0]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[0]"
            :loading="assetInfoSubTable.loading"
            :columns="assetInfoSubTable.columns"
            :dataSource="assetInfoSubTable.dataSource"
            :maxHeight="300"
            :disabled="disableSubmit"
            :rowNumber="true"
            :rowSelection="!disableSubmit"
            :actionButton="!disableSubmit"/>
        </a-tab-pane>
<!--        :disabledRows="{ roomStatus: 20 }"-->

      </a-tabs>

    </a-spin>
  </j-modal>
</template>

<script>

  import pick from 'lodash.pick'
  import { FormTypes, getRefPromise,VALIDATE_NO_PASSED,validateFormAndTables } from '@/utils/JEditableTableUtil'
  import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  import JDate from '@/components/jeecg/JDate'
  import JUpload from '@/components/jeecg/JUpload'
  import JImageUpload from '@/components/jeecg/JImageUpload'
  import JDictSelectTag from '@/components/dict/JDictSelectTag'
  import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
  import JTreeSelect from '@/components/jeecg/JTreeSelect'
  import { queryAssetImageByMainId } from '@/api/asset'
  import JCompanySelectTag from '@comp/jeecg/JCompanySelectTag'
  import maps from 'qqmap'
  import { ACCESS_TOKEN, IS_GROUP } from '@/store/mutation-types'
  import { getAction } from '../../../api/manage'

  export default {
    name: 'AssetInfoModal',
    mixins: [JEditableTableMixin],
    components: {
      JDate,
      JUpload,
      JImageUpload,
      JSearchSelectTag,
      JTreeSelect,
      JCompanySelectTag,
      JDictSelectTag
    },
    data () {
      return {

        //腾讯地图
        tencentMapUrl: '',
        images: '',
        latlng: {
          lng: 106.600782,
          lat: 29.718219
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 }
        },
        labelCol2: {
          xs: { span: 24 },
          sm: { span: 3 }
        },
        wrapperCol2: {
          xs: { span: 24 },
          sm: { span: 20 }
        },
        // 新增时子表默认添加几行空数据
        addDefaultRowNum: 0,
        disableSubmit: false,
        isDisposal: false,
        validatorRules: {
          // assetClass: {
          //   rules: [
          //     { required: true, message: '请输入取得方式!' }
          //   ]
          // },
          // // tnArea: {
          // //   rules: [
          // //     { required: true, message: '请输入套内面积!' }
          // //   ]
          // // },
          //
          // assetName: {
          //   rules: [
          //     { required: true, message: '请输入资产名称!' }
          //   ]
          // },
          // propertyRightUnit: {
          //   rules: [
          //     { required: true, message: '请输入产权单位!' }
          //   ]
          // },
          // // regionId: {
          // //   rules: [
          // //     { required: true, message: '请选择所属区域!' }
          // //   ]
          // // },
          //
          // propertyRightCode: {
          //   rules: [
          //     { required: false, message: '请输入产权证编号!' }
          //   ]
          // },
          // status: {
          //   rules: [
          //     { required: true, message: '请输入状态!' }
          //   ]
          // },
          // assetDisposal: {
          //   rules: [
          //     { required: false, message: '请选择处置类别!' }
          //   ]
          // },
          // floorNumber: {
          //   rules: [
          //     { required: false, message: '请输入楼层!' }
          //   ]
          // },
          // buildTime: {
          //   rules: [
          //     { required: false, message: '请输入建成年份!' }
          //   ]
          // },
          // houseStructure: {
          //   rules: [
          //     { required: false, message: '请输入结构!' }
          //   ]
          // },
          // houseUse: {
          //   rules: [
          //     { required: false, message: '请输入房屋用途!' }
          //   ]
          // },
          // site: {
          //   rules: [
          //     { required: true, message: '请输入坐落位置!' }
          //   ]
          // },
          // remark: {
          //   rules: [
          //     { required: false, message: '请输入备注!' }
          //   ]
          // },
          // // propertyRightArea: {
          // //   rules: [
          // //     { required: false, message: '请输入产权面积（m²）!' }
          // //   ]
          // // },
          // coveredArea: {
          //   rules: [
          //     { required: false, message: '请输入建筑面积（m²）!' }
          //   ]
          // },
          // landUseArea: {
          //   rules: [
          //     { required: false, message: '请输入出租面积（m²）!' }
          //   ]
          // },
          // // businessCircumstance: {
          // //   rules: [
          // //     { required: false, message: '请输入经营情况!' }
          // //   ]
          // // },
          // // receiptType: {
          // //   rules: [
          // //     { required: false, message: '请输入接收类型!' }
          // //   ]
          // // },
          // managementUnitId: {
          //   rules: [
          //     { required: false, message: '请输入管理单位!' }
          //   ]
          // },
          // // receiptTime: {
          // //   rules: [
          // //     { required: false, message: '请选择接收时间!' }
          // //   ]
          // // },
          // // landAuthorityType: {
          // //   rules: [
          // //     { required: false, message: '请选择权利类型!' }
          // //   ]
          // // },
          // rightCitizenshipSituation: {
          //   rules: [
          //     { required: false, message: '请选择权籍情况!' }
          //   ]
          // },
          // // ownershipSituation: {
          // //   rules: [
          // //     { required: false, message: '请选择权属情况!' }
          // //   ]
          // // },
          // holderRightName: {
          //   rules: [
          //     { required: false, message: '请选输入使用权人名称!' }
          //   ]
          // },
          // // licenseNumber: {
          // //   rules: [
          // //     { required: false, message: '请选输入使用权证号!' }
          // //   ]
          // // },
          // // collectionRate: {
          // //   rules: [
          // //     { required: false, message: '请选输入收款税率!' }
          // //   ]
          // // },
          // izMortgage: {
          //   rules: [
          //     { required: false, message: '请选择是否抵押!' }
          //   ]
          // }
        },
        refKeys: ['assetInfoSub'],
        tableKeys: ['assetInfoSub'],
        activeKey: 'assetInfoSub',
        // 资产明细
        assetInfoSubTable: {
          loading: false,
          dataSource: [],
          columns: [
            {
              title: '门牌号',
              key: 'roomName',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }]
            },
            {
              title: '面积（m²）',
              key: 'roomArea',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}',
              defaultValue: '',
              validateRules: [{ required: true, message: '${title}不能为空' }]
            },
            {
              title: '状态',
              key: 'roomStatus',
              type: FormTypes.select,
              // disabled: true,
              dictCode: 'zcgl_asset_status',
              width: '200px',
              placeholder: '请选择${title}',
              valueExclude: [1,20],
              // valueText: [10,30,40,50,60,70],
              defaultValue: '10',
              validateRules: [{ required: true, message: '${title}不能为空' }]
            },
            // {
            //   title: '上会时间',
            //   key: 'meetingTime',
            //   type: FormTypes.input,
            //   width: '200px',
            //   placeholder: '请输入${title}'
            // },
            // {
            //   title: '价值（万元）',
            //   key: 'worth',
            //   type: FormTypes.inputNumber,
            //   width: '200px',
            //   placeholder: '请输入${title}'
            // },
            {
              title: '空置原因',
              key: 'emptyReason',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}'
            },
            {
              title: '具体问题',
              key: 'concreteIssue',
              type: FormTypes.input,
              width: '200px',
              placeholder: '请输入${title}'
            }
          ]
        },
        url: {
          add: '/zcgl/assetInfo/add',
          edit: '/zcgl/assetInfo/edit',
          assetInfoSub: {
            list: '/zcgl/assetInfo/queryAssetInfoSubByMainId'
          },
          getAssetCode:'/zcgl/assetInfo/getAssetCode'
        }
      }
    },
    watch: {
      showModal: function (newValue) {
        if (newValue) {
          this.init()
        }
      }
    },
    mounted () {
      let that = this
      window.addEventListener('message', function (event) {
        // 对于无法识别的地址，直接返回无法选择
        let loc = event.data
        // if (loc.poiname === '我的位置' || loc.poiaddress === '') {
        //   console.log('无法识别该地址，请移动地图重新选择')
        //   return false
        // }
        if (loc && loc.module === 'locationPicker') { // 防止其他应用也会向该页面post信息，需判断module是否为'locationPicker'
          console.log('callback', loc)
          that.latlng = loc.latlng

          // that.latlng.lat = loc.latlng.lat
          // that.latlng.lng = loc.latlng.lng
          // console.log(this.latlng)
          // this.setLatlng(loc)
        }
      }, false)
    },

    // computed: {
    //   getSrc () {
    //     let tencentMapUrl1 = `${window._CONFIG['tencentMapUrl']}`
    //     if (this.model.lat && this.model.lng) {
    //       tencentMapUrl1 += `&coord=${this.lat},${this.lng}`
    //     }
    //     this.tencentMapUrl = encodeURIComponent(tencentMapUrl1)
    //   }
    // },

    methods: {
      //初始化地图
      init () {
        var that = this
        maps.init(`${window._CONFIG['tencentMapKey']}`, () => {
          let myLatlng = new qq.maps.LatLng(that.latlng.lat, that.latlng.lng)
          let myOptions = {
            zoom: 16,
            center: myLatlng,
            mapTypeId: qq.maps.MapTypeId.ROADMAP
          }
          let map = new qq.maps.Map(
            document.getElementById('container'),
            myOptions
          )
          let marker = new qq.maps.Marker({
            position: myLatlng,
            map: map
          })
        })
      },
      getAllTable () {
        let values = this.tableKeys.map(key => getRefPromise(this, key))
        return Promise.all(values)
      },
      /** 调用完edit()方法之后会自动调用此方法 */
      editAfter () {
        this.images = ''

        let isGroup = sessionStorage.getItem(IS_GROUP)
        if (isGroup == 1) {
          let companyName = {
            rules: [{
              required: false, message: '请选择所属公司!'
            }]
          }
          this.validatorRules.companyId = companyName
        }
        let tencentMapUrl1 = `${window._CONFIG['tencentMapUrl']}`
        if (this.model.latitude && this.model.longitude) {
          this.latlng.lat = this.model.latitude
          this.latlng.lng = this.model.longitude
          tencentMapUrl1 += `&coord=${this.model.latitude},${this.model.longitude}`
        } else {
          // this.latlng.lat = 0
          // this.latlng.lng = 0
        }

        this.tencentMapUrl = tencentMapUrl1
        // console.log(this.tencentMapUrl)
        if(this.model.status == 1){
          this.model.status = this.model.initStatus
        }

        this.statusChange(this.model.status)

        this.$nextTick(() => {
          this.init()
          let keys = Object.keys(this.form.formItems);
          this.form.setFieldsValue(pick(this.model, keys))
          // this.form.setFieldsValue(fieldval)
        })
        // 加载子表数据
        if (this.model.id) {
          let params = { id: this.model.id }
          this.requestSubTableData(this.url.assetInfoSub.list, params, this.assetInfoSubTable)
          this.getImages()
        }
      },
      statusChange(val){
        if (val == 40){
          this.isDisposal = true
          // this.validatorRules.assetDisposal.rules[0].required = true
        } else {
          this.isDisposal = false
          // this.validatorRules.assetDisposal.rules[0].required = false
        }
      },
      /** 整理成formData */
      classifyIntoFormData (allValues) {
        let that = this
        let main = Object.assign(this.model, allValues.formValue)
        main.latitude = this.latlng.lat
        main.longitude = this.latlng.lng

        let assetImageList = []
        if (this.images && this.images.split(',') != '') {
          this.images.split(',').forEach((v, i) => {
            assetImageList.push({
              imageUrl: v,
              type: 0,
              assetId: that.model.id
            })
          })
        }
        main.assetImageList = assetImageList
        return {
          ...main, // 展开
          assetInfoSubList: allValues.tablesValue[0].values
        }
      },
      validateError (msg) {
        this.$message.error(msg)
      },
      popupCallback (row) {
        let keys = Object.keys(this.form.formItems);
        this.form.setFieldsValue(pick(row, keys))
      },
      getImages () {
        let that = this
        queryAssetImageByMainId({ id: this.model.id }).then((res) => {
          if (res.success) {
            if (res.result && res.result.length > 0) {
              let fileList = []
              res.result.forEach((v, i) => {
                // if (that.disableSubmit){
                //   that.repairImageList.push(getFileAccessHttpUrl(v.imageUrl))
                // } else {
                  fileList.push(v.imageUrl)
                // }
              })
              that.images = fileList.join(',')
            }
          } else {
            that.images = ''
          }
        }).finally(() => {
          // that.$previewRefresh()
        })
      },
      /** 确定按钮点击事件 */
      handleOk() {
        /** 触发表单验证 */
        this.getAllTable().then(tables => {
          /** 一次性验证主表和所有的次表 */
          return validateFormAndTables(this.form, tables)
        }).then(allValues => {




          if (typeof this.classifyIntoFormData !== 'function') {
            throw this.throwNotFunction('classifyIntoFormData')
          }
          let formData = this.classifyIntoFormData(allValues)
          formData.status = this.form.getFieldValue('status')
          // 发起请求
          return this.request(formData)
        }).catch(e => {
          if (e.error === VALIDATE_NO_PASSED) {
            // 如果有未通过表单验证的子表，就自动跳转到它所在的tab
            this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index]
          } else {
            console.error(e)
          }
        })
      },
      getAssetCode(e){
        let param={
          companyId:e
        }
        getAction(this.url.getAssetCode,param).then(res=>{
          if(res.success){
            this.form.setFieldsValue({assetCode:res.message})
          }
        })
      }
    }
  }
</script>

<style scoped>
</style>